﻿<UserControl x:Class="Scrabble.Views.PoolView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Controls="clr-namespace:Scrabble.Controls" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary Source="/Themes/DataGridStyles.xaml" />
    </UserControl.Resources>
    <Grid>
        <Grid.Resources>
            <Style x:Key="CenterAlignCellStyle" BasedOn="{StaticResource CellWithoutSelection}" TargetType="DataGridCell">
                <Setter Property="TextBlock.TextAlignment" Value="Center"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding TotalInPool}" Value="0">
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <DataTemplate x:Key="TileGauge">
                <Controls:BlockGauge Maximum="{Binding TotalInGame}" Value="{Binding TotalInPool}" BlockWidth="6" GapWidth="2" VerticalContentAlignment="Center" Margin="2" SnapsToDevicePixels="True" >
                    <Controls:BlockGauge.ToolTip>
                        <ToolTip>
                            <TextBlock><Run Text="{Binding TotalInPool, Mode=OneWay}" /> of <Run Text="{Binding TotalInGame, Mode=OneWay}"/> remaining</TextBlock>
                        </ToolTip>
                    </Controls:BlockGauge.ToolTip>
                </Controls:BlockGauge>
            </DataTemplate>
        </Grid.Resources>
        <DataGrid ItemsSource="{Binding Statistics}" Style="{StaticResource DataGridStyle}" CellStyle="{StaticResource CellWithoutSelection}"  >
            <DataGrid.Columns>
                <DataGridTextColumn Header="Letter" Binding="{Binding Letter}" MinWidth="30" CellStyle="{StaticResource CenterAlignCellStyle}" />
                <DataGridTemplateColumn Header="Remaining" CellTemplate="{StaticResource TileGauge}" Width="110" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
